home *** CD-ROM | disk | FTP | other *** search
- /* t3dlib.h - definitions needed to interface to TTDDD library
- * - written by Glenn M. Lewis - 7/19/91
- * - Imagine3.0 staging file extensions by Rob Hounsell - Sept 94
- * $Id: t3dlib.h,v 1.28 1995/02/01 22:24:38 glewis Exp glewis $
- */
-
- #ifdef AMIGA
-
- #ifdef _M68881
- #include <m68881.h>
- #endif
-
- /* The following has been tested using SAS/C on an Amiga by Helge Rasmussen */
- #ifdef __SASC
- #include <string.h>
- #include <stdlib.h>
- #include <exec/types.h>
- #else
- #define bcopy(s,d,n) (void)memcpy((d),(s),(n))
- #define bzero(d,n) (void)memset((d),0,(n))
- #define bcmp(b1,b2,n) memcmp((b1),(b2),(n))
- #define index strchr
- #define rindex strrchr
- #endif
-
- #else
-
- #include <strings.h>
- #include <malloc.h>
- /*char *calloc();*/
-
- #endif
-
- #ifdef SYSV
- extern char *memcpy(), *memset();
- #define bcopy(s,d,n) (void)memcpy((d),(s),(n))
- #define bzero(d,n) (void)memset((d),0,(n))
- #define bcmp(b1,b2,n) memcmp((b1),(b2),(n))
- #define index strchr
- #define rindex strrchr
- #endif
-
- #ifndef AMIGA
- #ifndef UBYTE
- #define UBYTE unsigned char
- #endif
- #ifndef BYTE
- #define BYTE char
- #endif
-
- #ifndef UWORD
- #define UWORD unsigned short
- #endif
- #ifndef WORD
- #define WORD short
- #endif
-
- #ifndef ULONG
- #define ULONG unsigned long
- #endif
- #ifndef LONG
- #define LONG long
- #endif
- #endif
-
- #ifndef FRACT
- #define FRACT double
- #endif
-
- typedef struct { double x,y,z; } XYZ_st; /* Used to be val[3] */
- typedef struct { UBYTE r,g,b; } RGB_st; /* Used to be val[3] */
- typedef struct { XYZ_st came, rota; double foca; } OBSV;
- typedef struct { double at, by; RGB_st to; } FADE;
- typedef struct { RGB_st hori, zeni; } SKYC;
- typedef char BRSH[81];
- typedef struct { XYZ_st tran, scal, rota1, rota2, rota3; } MTRX;
- typedef struct { XYZ_st xaxi, yaxi, zaxi; } AXIS;
- typedef struct { char path[19]; XYZ_st tran, rota, scal; UWORD info; } STRY;
- typedef struct {
- MTRX mtrx;
- char filename[81];
- } EXTR;
- typedef struct {
- UBYTE type;
- float indx;
- } MTTR;
- struct OBJECT {
- EXTR *extr; /* Either EXTR or DESC */
- struct DESC *desc;
- struct OBJECT *parent; /* whose child this OBJECT is */
- struct OBJECT *child; /* children of this OBJECT - not for EXTR */
- struct OBJECT *next; /* At this level in the hierarchy */
- void *user; /* User-defined data for any purpose */
- };
- typedef struct OBJECT OBJECT;
- typedef struct {
- UWORD num;
- UBYTE *eflg;
- } EFLG;
- struct FGRP {
- struct FGRP *next; /* Linked list */
- UWORD num;
- char name[19]; /* 18 allowed in file */
- UWORD *face;
- };
- typedef struct FGRP FGRP;
- typedef struct {
- UWORD Flags;
- MTRX TAxis;
- double Params[16];
- UBYTE PFlags[16];
- UBYTE SubName[81];
- UBYTE Length;
- UBYTE Name[81];
- } TXT2;
- typedef struct DESC {
- char name[19];
- WORD *shap;
- XYZ_st *posi;
- AXIS *axis;
- XYZ_st *size;
- XYZ_st *pnts;
- RGB_st *colr, *refl, *tran, *spc1;
- UWORD *edge, *face, pcount, ecount, fcount;
- UBYTE *clst, *rlst, *tlst;
- double *tpar;
- UBYTE *surf;
- MTTR *mttr;
- UBYTE *spec;
- UBYTE *prp0, *prp1;
- double *ints;
- XYZ_st *int1;
- STRY *stry;
- FGRP *fgrp;
- EFLG *eflg;
- TXT2 *txt2[4];
- } DESC;
-
- /* extern UBYTE defclst[3], defrlst[3], deftlst[3], defspc1[3]; */
-
- /* Add staging FILE information for Imagine support */
- /* It appears that the staging FILEs use 3 FRACT's to represent colors
- * instead of 3 UBYTEs... Hmmm...
- */
-
- /* Imagine 2 Chunks: OSIZ, POSN, ALGN, GLB2, LITE, HING, SFILE */
- /* Imagine 3 Chunks: OSZ2, POS2, ALN2, GLB3, LIT2, ASSC, LYR0, FIL3, S3FX, */
- /* S4FX */
- /* Common Chunks: PALN, PTH2, TALN, SAXIS, SPFX, S2FX */
-
- enum chunk_type {OSIZ_CHUNK,
- POSN_CHUNK,
- ALGN_CHUNK,
- PALN_CHUNK,
- PTH2_CHUNK,
- TALN_CHUNK,
- GLB2_CHUNK,
- SAXIS_CHUNK,
- LITE_CHUNK,
- HING_CHUNK,
- SFILE_CHUNK,
- OSZ2_CHUNK,
- POS2_CHUNK,
- ALN2_CHUNK,
- GLB3_CHUNK,
- LIT2_CHUNK,
- ASSC_CHUNK,
- LYR0_CHUNK,
- FIL3_CHUNK,
- SPFX_CHUNK,
- S2FX_CHUNK,
- S3FX_CHUNK,
- S4FX_CHUNK };
-
-
- struct SAXIS { struct SAXIS *next, *prev; UBYTE chunk_type; UWORD flags, start, stop; };
- typedef struct SAXIS SAXIS;
-
- struct GLB2 {
- struct GLB2 *next, *prev;
- UBYTE chunk_type;
- UWORD flags, start, stop;
- ULONG sky_blending;
- double starfield;
- ULONG transition;
- /* The following are really colors */
- XYZ_st ambient, horizon, zenith1, zenith2, fog_color;
- double fog_bottom, fog_top, fog_length;
- ULONG brush_seq, backdrop_seq;
- char backdrop[256]; /* Fixed length */
- char globalbrush[256]; /* Variable length */
- };
- typedef struct GLB2 GLB2;
-
- struct LITE {
- struct LITE *next, *prev;
- UBYTE chunk_type;
- UWORD flags, start, stop;
- /* The following are really colors */
- XYZ_st color;
- ULONG transition;
- };
- typedef struct LITE LITE;
-
- struct SFILE {
- struct SFILE *next, *prev;
- UBYTE chunk_type;
- UWORD flags, start, stop;
- double cycles_to_perform;
- double initial_cycle_phase;
- ULONG transition;
- char object_description[256]; /* Variable length */
- };
- typedef struct SFILE SFILE;
-
- struct OSIZ { struct OSIZ *next,*prev; UBYTE chunk_type; UWORD flags, start, stop; XYZ_st size; };
- typedef struct OSIZ OSIZ; /* Size */
-
- struct POSN { struct POSN *next,*prev; UBYTE chunk_type; UWORD flags, start, stop; XYZ_st posn; };
- typedef struct POSN POSN; /* Position */
-
- struct ALGN { struct ALGN *next,*prev; UBYTE chunk_type; UWORD flags, start, stop; XYZ_st algn; };
- typedef struct ALGN ALGN; /* Alignment */
-
- struct HING {
- struct HING *next, *prev;
- UBYTE chunk_type;
- UWORD flags, start, stop;
- char hingeobj[256]; /* Variable length */
- };
- typedef struct HING HING; /* Hinge */
-
- struct GLB3 {
- struct GLB3 *next, *prev;
- UBYTE chunk_type;
- UWORD flags, start, stop;
- ULONG brush_seq;
- double starfield;
- ULONG transition;
- /* The following are really colors */
- XYZ_st ambient, horizon, zenith1, zenith2, fog_color;
- double fog_bottom, fog_top, fog_length;
- ULONG backdrop_seq;
- char backdrop[256]; /* Fixed length */
- char globalbrush[256]; /* Variable length */
- };
- typedef struct GLB3 GLB3;
-
- struct LIT2 {
- struct LIT2 *next, *prev;
- UBYTE chunk_type;
- UWORD flags, start, stop;
- /* The following are really colors */
- XYZ_st color;
- ULONG transition;
- };
- typedef struct LIT2 LIT2;
-
- struct FIL3 {
- struct FIL3 *next, *prev;
- UBYTE chunk_type;
- UWORD flags, start, stop;
- double cycles_to_perform;
- double initial_cycle_phase;
- double vel_0, vel_1;
- char state[18]; /* Fixed length */
- char object_description[256]; /* Variable length */
- };
- typedef struct FIL3 FIL3;
-
- struct OSZ2 { struct OSZ2 *next,*prev; UBYTE chunk_type; UWORD flags, start, stop; XYZ_st size; double vel_0, vel_1; };
- typedef struct OSZ2 OSZ2; /* Size */
-
- struct POS2 { struct POS2 *next,*prev; UBYTE chunk_type; UWORD flags, start, stop; XYZ_st pos2; double vel_0, vel_1;};
- typedef struct POS2 POS2; /* Position */
-
- struct ALN2 { struct ALN2 *next,*prev; UBYTE chunk_type; UWORD flags, start, stop; XYZ_st aln2; double vel_0, vel_1; };
- typedef struct ALN2 ALN2; /* Alignment */
-
- struct PALN { struct PALN *next,*prev; UBYTE chunk_type; UWORD flags, start, stop; };
- typedef struct PALN PALN; /* Path Alignment */
-
- struct PTH2 {
- struct PTH2 *next, *prev;
- UBYTE chunk_type;
- UWORD flags, start, stop;
- ULONG acceleration_frames;
- double start_speed;
- ULONG deacceleration_frames;
- double end_speed;
- char path[256]; /* Variable length */
- };
- typedef struct PTH2 PTH2; /* Follow Path */
-
- struct TALN {
- struct TALN *next, *prev;
- UBYTE chunk_type;
- UWORD flags, start, stop;
- double initial_y, final_y;
- char trackobj[256]; /* Variable length */
- };
- typedef struct TALN TALN; /* Track alignment */
-
- struct ASSC {
- struct ASSC *next, *prev;
- UBYTE chunk_type;
- UWORD flags, start, stop;
- char assc_obj[18]; /* Fixed length */
- };
- typedef struct ASSC ASSC; /* Associate chunk */
-
- struct LYR0 {
- struct LYR0 *next, *prev;
- UBYTE chunk_type;
- UWORD layer;
- };
- typedef struct LYR0 LYR0; /* Layer info */
-
- struct SPFX {
- struct SPFX *next, *prev;
- UBYTE chunk_type;
- UWORD flags, start, stop;
- char effect[256]; /* Variable length */
- char effect_data[512]; /* uuencoded data, variable length */
- };
- typedef struct SPFX SPFX; /* Special Effects chunk */
-
- struct SOBJ {
- struct SOBJ *next, *prev;
- /* Required subchunks in the SOBJ chunk... */
- char name[18]; /* CHUNK: Name, fixed=18 */
- UWORD stgf; /* CHUNK: always zero? */
- /* Possible subchunks in the SOBJ chunk, including Imagine 2.0 & 3.0 */
- OSZ2 *osz2; /* V3 Size */
- OSIZ *osiz; /* V2 Size */
- POS2 *pos2; /* V3 Position */
- POSN *posn; /* V2 Position */
- ALN2 *aln2; /* V3 Alignment */
- ALGN *algn; /* V2 Alignment */
- GLB3 *glb3; /* V3 Globals */
- GLB2 *glb2; /* V2 Globals */
- SAXIS *axis; /* Stagefile AXIS */
- LIT2 *lit2; /* V3 Light */
- LITE *lite; /* V2 Light */
- ASSC *assc; /* V3 Associate object */
- HING *hing; /* V2 Hinge */
- LYR0 *lyr0; /* layer in stage editor */
- FIL3 *fil3; /* V3 external file */
- SFILE *file; /* V2 external file */
- SPFX *spfx; /* Special Effect */
- SPFX *s2fx; /* Special Effect 2 */
- SPFX *s3fx; /* Special Effect 3 */
- SPFX *s4fx; /* Special Effect 4 */
- };
- typedef struct SOBJ SOBJ;
-
- typedef struct {
- UWORD maxf, loop;
- /* Just so we don't have to search through the doubly-linked list */
- /* every time we wish to add to the tail, keep a pointer to head&tail */
- SOBJ *head, *tail;
- } ISTG;
-
- /* Back to old Turbo Silver stuff... */
-
- #define STNC BRSH
- #define TXTR BRSH
- typedef struct {
- BRSH brsh[8];
- STNC stnc[8];
- TXTR txtr[8];
- OBSV *obsv;
- BYTE otrk[19];
- STRY *ostr;
- FADE *fade;
- SKYC *skyc;
- RGB_st *ambi;
- BYTE *glb0;
- } INFO;
-
- typedef struct {
- INFO *info; /* The INFO description in the file */
- ISTG *istg; /* Imagine staging file */
- OBJECT *object; /* The first object in the world */
- void *user; /* User-defined data for any purpose */
- /* Some private variables needed to parse input file - don't touch! */
- int num_OBJ, num_DESC, num_TOBJ, cur_line;
- FILE *inp;
- OBJECT *curobj;
- } WORLD;
-
- typedef struct {
- double minx, maxx, miny, maxy, minz, maxz;
- } MBB;
-
- #ifdef __STDC__
- #define P0() void
- #define P1(a) a
- #define P2(a,b) a,b
- #define P3(a,b,c) a,b,c
- #define P4(a,b,c,d) a,b,c,d
- #define P5(a,b,c,d,e) a,b,c,d,e
- #else
- #define P0()
- #define P1(a)
- #define P2(a,b)
- #define P3(a,b,c)
- #define P4(a,b,c,d)
- #define P5(a,b,c,d,e)
- #endif
-
- WORLD *read_World(P1(FILE*)); /* world = read_World(FILE *); ..figures out format */
- WORLD *free_World(P1(WORLD*)); /* world = free_World(world *); ...frees a WORLD* */
- void merge_World(P1(WORLD*)); /* merge_World(world *); ..optimizes points & edges */
- WORLD *read_TTDDD(P1(FILE*)); /* world = read_TTDDD(FILE *); ...0 on failure */
- WORLD *read_TDDD(P1(FILE*)); /* world = read_TDDD(FILE *); ...0 on failure */
- WORLD *read_LWOB(P1(FILE*)); /* world = read_LWOB(FILE *); ...0 on failure */
- WORLD *read_ISTG(P1(FILE*)); /* world = read_ISTG(FILE *); ...0 on failure */
- int write_TTDDD(P2(WORLD*,FILE*)); /* write_TTDDD(world *, FILE *); ...0 on failure */
- int write_TDDD(P2(WORLD*,FILE*)); /* write_TDDD(world *, FILE *); ...0 on failure */
- int write_Rayshade(P2(WORLD*,FILE*)); /* write_Rayshade(world *, FILE *); ...0 on failure */
- int write_PostScript(P3(WORLD*,FILE*,int)); /* write_PostScript(world *, FILE *, view); ..ditto */
- int write_MIF(P3(WORLD*,FILE*,int)); /* write_MIF(world *, FILE *, view); ..0 on failure */
- void calculate_MBB_world(P1(WORLD*)); /* calculate_MBB_world(WORLD *); */
- void calculate_MBB(P1(OBJECT*)); /* calculate_MBB(OBJECT *); */
- OBJECT *linear_morph(P3(OBJECT*,OBJECT*,double)); /* linear_morph(obj1, obj2, time); /* 0.0<=time<=1.0 */
- OBJECT *create_object(P0()); /* p = create_object(); */
- OBJECT *free_object(P1(OBJECT*)); /* from freeworld.c */
- int count_objects(P2(OBJECT*,OBJECT**)); /* Used by "morph()" */
- int morph(P5(WORLD*,WORLD*,int,char*,OBJECT*(*func)())); /* morph(world1, world2, num, name, morph_function); */
- void free_desc(P1(DESC*)); /* free_desc(DESC *); */
- void match_points(P3(int,OBJECT*,OBJECT*)); /* match_points(numpoints, obj1, obj2); */
- void sort_points(P2(DESC*,int(*cmp)()));
- int cmpXYZ(P2(XYZ_st*,XYZ_st*)); /* comparison for sort_points */
- void move_extr(P2(OBJECT*,MTRX*));
- void OUT_MEM(P1(char*));
- void load_staging_frame_objects(P2(WORLD*,int)); /* (world, frame); load a frame's objects */
- int write_OFF(P4(WORLD*,char*,int,int));
- int write_NFF(P2(WORLD*,FILE*));
- int write_DXF(P2(WORLD*,FILE*));
- int write_POVRay(P2(WORLD*,FILE*));
- int write_Vort(P2(WORLD*,FILE*));
- int write_LWOB(P2(WORLD*,FILE*));
-
- /* Some stuff for PostScript and MIF output */
- extern double XSIZE, YSIZE; /* (in inches) Default: 8.5x11.0 */
-
- #define VIEW_TOP 0 /* eye at (0,0,+inf) */
- #define VIEW_FRONT 1 /* eye at (0,-inf,0) */
- #define VIEW_ISO 2 /* eye at (+inf,-inf,+inf) */
- #define VIEW_RIGHT 3 /* eye at (+inf,0,0) */
- #define VIEW_ALL_FOUR 4 /* Place all on the same page */
-